package com.tencent.txcc.controller;

import com.tencent.txcc.domain.CourseDoc;
import com.tencent.txcc.dto.CourseSearchDto;
import com.tencent.txcc.result.JSONResult;
import com.tencent.txcc.result.PageList;
import com.tencent.txcc.service.IESService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/course")
public class ESController {

    @Autowired
    private IESService esService;

    @RequestMapping(value="/courseEsAdd",method= RequestMethod.POST)
    public JSONResult courseEsAdd(@RequestBody CourseDoc courseDoc){
        esService.courseEsAdd(courseDoc);
        return JSONResult.success();
    }

    @RequestMapping(value="/courseEsDel",method= RequestMethod.POST)
    public JSONResult courseEsDel(@RequestBody Long id){
        esService.courseEsDel(id);
        return JSONResult.success();
    }

    @RequestMapping(value="/search",method= RequestMethod.POST)
    public JSONResult courseSearch(@RequestBody CourseSearchDto courseSearchDto){
        PageList<CourseDoc> pageList= esService.courseSearch(courseSearchDto);
        return JSONResult.success(pageList);
    }


}
